using System;
using System.Data;
using System.Collections.Generic;
using Soccer.Core;
using Soccer.Utility;

namespace Soccer.Business
{
    [TableAttribute("Categories")]
	[Serializable]
    public class Category : DBO<Category>
    {
		#region Fields
		
		private int? _IdCategory;
		private string _Title;
		private bool? _IsActived;
		private DateTime? _CreatedDate;
		private DateTime? _LastModifiedDate;
		private int? _IdParent;
		private string _Description;
		private int? _SortOrder;
		
		#endregion
		
		#region Constructors
		/// <summary>
		/// Default constructor
		/// </summary>
		public Category()
		{
			
		}
		
		/// <summary>
		/// Constructor with IdCategory 
		/// </summary>
		/// <param name="IdCategory">The IdCategory</param>
		public Category(int? IdCategory )
		{
			this.IdCategory = IdCategory;
		}
		
		/// <summary>
		/// Constructor with all parameters
		/// </summary>
		/// <param name="IdCategory">Sets int? value for IdCategory</param>
		/// <param name="Title">Sets string value for Title</param>
		/// <param name="IsActived">Sets bool? value for IsActived</param>
		/// <param name="CreatedDate">Sets DateTime? value for CreatedDate</param>
		/// <param name="LastModifiedDate">Sets DateTime? value for LastModifiedDate</param>
		/// <param name="IdParent">Sets int? value for IdParent</param>
		/// <param name="Description">Sets string value for Description</param>
		/// <param name="SortOrder">Sets int? value for SortOrder</param>
		public Category(int? idCategory, string title, bool? isActived, DateTime? createdDate, DateTime? lastModifiedDate, int? idParent, string description, int? sortOrder)
		{
			this.IdCategory = idCategory;
			this.Title = title;
			this.IsActived = isActived;
			this.CreatedDate = createdDate;
			this.LastModifiedDate = lastModifiedDate;
			this.IdParent = idParent;
			this.Description = description;
			this.SortOrder = sortOrder;
		}
		
		#endregion
		
		#region Properties
		
		/// <summary>
		/// Gets or sets int? value for IdCategory
		/// </summary>
		[ColumnAttribute("IdCategory", SqlDbType.Int , 4 , true, true, false)]
		public int? IdCategory
		{
			set
			{
				this._IdCategory = value;
			}
			get
			{
				return this._IdCategory;
			}
		}
		
		/// <summary>
		/// Gets or sets string value for Title
		/// </summary>
		[ColumnAttribute("Title", SqlDbType.NVarChar , 1000 , false, false, true)]
		public string Title
		{
			set
			{
				this._Title = value;
			}
			get
			{
				return this._Title;
			}
		}
		
		/// <summary>
		/// Gets or sets bool? value for IsActived
		/// </summary>
		[ColumnAttribute("IsActived", SqlDbType.Bit , 1 , false, false, true)]
		public bool? IsActived
		{
			set
			{
				this._IsActived = value;
			}
			get
			{
				return this._IsActived;
			}
		}
		
		/// <summary>
		/// Gets or sets DateTime? value for CreatedDate
		/// </summary>
		[ColumnAttribute("CreatedDate", SqlDbType.DateTime , 8 , false, false, true)]
		public DateTime? CreatedDate
		{
			set
			{
				this._CreatedDate = value;
			}
			get
			{
				return this._CreatedDate;
			}
		}
		
		/// <summary>
		/// Gets or sets DateTime? value for LastModifiedDate
		/// </summary>
		[ColumnAttribute("LastModifiedDate", SqlDbType.DateTime , 8 , false, false, true)]
		public DateTime? LastModifiedDate
		{
			set
			{
				this._LastModifiedDate = value;
			}
			get
			{
				return this._LastModifiedDate;
			}
		}
		
		/// <summary>
		/// Gets or sets int? value for IdParent
		/// </summary>
		[ColumnAttribute("IdParent", SqlDbType.Int , 4 , false, false, true)]
		public int? IdParent
		{
			set
			{
				this._IdParent = value;
			}
			get
			{
				return this._IdParent;
			}
		}
		
		/// <summary>
		/// Gets or sets string value for Description
		/// </summary>
		[ColumnAttribute("Description", SqlDbType.NVarChar , -1 , false, false, true)]
		public string Description
		{
			set
			{
				this._Description = value;
			}
			get
			{
				return this._Description;
			}
		}
		
		/// <summary>
		/// Gets or sets int? value for SortOrder
		/// </summary>
		[ColumnAttribute("SortOrder", SqlDbType.Int , 4 , false, false, true)]
		public int? SortOrder
		{
			set
			{
				this._SortOrder = value;
			}
			get
			{
				return this._SortOrder;
			}
		}
		
		/// <summary>
		/// Get a Category object of current object base on IdParent
		/// </summary>
		public Category ParentCategory
		{
			get
			{
				if (this.IdParent == null)
					return null;
					
				Category condition = new Category(this.IdParent);
				return CategoryController.FindItem(condition);
			}
		}
		
		/// <summary>
		/// Get a list NewsCategory of current Category object base on IdCategory
		/// </summary>
		public List<NewsCategory> NewsCategoryListForIdCategory
		{
			get
			{
				if (this.IdCategory == null)
					return null;
				NewsCategory condition = new NewsCategory();
				condition.IdCategory = this.IdCategory;
				return NewsCategoryController.FindItems(condition);
			}
		}
		
		#endregion
        
        #region Other Properties
        private static ColumnNameStruct? _ColumnName;
        public static ColumnNameStruct ColumnName
        {
            get
            {
                if (!_ColumnName.HasValue)
                    _ColumnName = new ColumnNameStruct();
                return _ColumnName.Value;
            }
        }
        #endregion

        #region NestedType
        public  struct ColumnNameStruct
        {
            /// <summary>
            /// Get the name of column [IdCategory]
            /// </summary>
            public string IdCategory
            {
                get
                {
                    return "IdCategory";
                }
            }
            /// <summary>
            /// Get the name of column [Title]
            /// </summary>
            public string Title
            {
                get
                {
                    return "Title";
                }
            }
            /// <summary>
            /// Get the name of column [IsActived]
            /// </summary>
            public string IsActived
            {
                get
                {
                    return "IsActived";
                }
            }
            /// <summary>
            /// Get the name of column [CreatedDate]
            /// </summary>
            public string CreatedDate
            {
                get
                {
                    return "CreatedDate";
                }
            }
            /// <summary>
            /// Get the name of column [LastModifiedDate]
            /// </summary>
            public string LastModifiedDate
            {
                get
                {
                    return "LastModifiedDate";
                }
            }
            /// <summary>
            /// Get the name of column [IdParent]
            /// </summary>
            public string IdParent
            {
                get
                {
                    return "IdParent";
                }
            }
            /// <summary>
            /// Get the name of column [Description]
            /// </summary>
            public string Description
            {
                get
                {
                    return "Description";
                }
            }
            /// <summary>
            /// Get the name of column [SortOrder]
            /// </summary>
            public string SortOrder
            {
                get
                {
                    return "SortOrder";
                }
            }
        }
        #endregion
    }
}
